<?php

namespace App\Http\Service;

use App\Models\History;
use App\Models\SiteConfig;
use App\Http\Service\BaseService;
use Illuminate\Support\Facades\Config;
class SiteConfigService  extends BaseService
{
    private $model;
    public function __construct(SiteConfig $model)
    {
        parent::__construct();
        $this->model = $model;
    }

    #获取站点信息
    public function getList($type)
    {
        if($type){
            $first=$this->model->where(['type'=>$type])->first();
            $first['content']=json_decode($first['content'],true);
            //dd($first['content']);
        }else{
            $list=$this->model->select()->get()->toArray();
            $first=[];
            foreach ($list as $k => &$v) {
                $v['content']=json_decode($v['content'],true);
                $first[$v['type']]=$v['content'];
            }
        }
        return $first;
        
    }
}
